package com.cyurs.netty.nio;

import java.nio.Buffer;
import java.nio.IntBuffer;
import java.nio.channels.FileChannel;

/**
 * @Author: Cyrus
 * @CreateDate: 2020/11/15
 */
public class BufferDemo {
    public static void main(String[] args) {

        IntBuffer buffer = IntBuffer.allocate(5);


        for (int i = 0; i < buffer.capacity(); i++) {
            buffer.put(i * 2);
        }
        buffer.flip();//buffer读写切换
        while (buffer.hasRemaining()) {
            System.out.print(buffer.get()+" ");
        }

    }
}
